package net.cctms.zhishu.webAppFramework.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * 文章图片实体
 *
 * Created by caot on 2016/1/20.
 */
public class PicEntity implements Parcelable,Cloneable ,Serializable{
    public String id;
    public String picUrl;
    public String originalPicUrl;
    public String keyGifPicUrl;
    public int picWidth;
    public int picHeight;

    public int isGif;//是否为Gif图片 0普通图片，1为gif图片
    public int isKeyGif;//是否为Gif 0非第一帧，1为第一帧
    public int isPicLoad;//是否加载完毕 0或者空表示未加载，1为加载完毕,其中不包括gif第一帧加载完毕
    public int isFail;//是否加载成功 0或者空为成功，1代表失败
    //public int isLoading;


    @Override
    public PicEntity clone() {
        try {
            return (PicEntity)super.clone();
        } catch (CloneNotSupportedException e) {
            return copy();
        }
    }

    public PicEntity copy(){

        PicEntity picEntity = new PicEntity();

        picEntity.picUrl = this.picUrl;
        picEntity.id = this.id;
        picEntity.originalPicUrl = this.originalPicUrl;
        picEntity.keyGifPicUrl = this.keyGifPicUrl;
        picEntity.picHeight = this.picHeight;
        picEntity.picWidth = this.picWidth;

        picEntity.isKeyGif = this.isKeyGif;
        picEntity.isFail = this.isFail;
        picEntity.isGif = this.isGif;
        picEntity.isPicLoad = this.isPicLoad;

        return picEntity;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<PicEntity> CREATOR = new Creator<PicEntity>() {
        @Override
        public PicEntity[] newArray(int size) {
            return new PicEntity[size];
        }

        @Override
        public PicEntity createFromParcel(Parcel in) {
            return new PicEntity(in);
        }
    };

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(picUrl);
        dest.writeString(originalPicUrl);
        dest.writeString(keyGifPicUrl);
        dest.writeInt(picWidth);
        dest.writeInt(picHeight);
        dest.writeInt(isGif);
        dest.writeInt(isKeyGif);
        dest.writeInt(isPicLoad);
        dest.writeInt(isFail);
    }

    public PicEntity(){

    }

    private PicEntity(Parcel in) {
        id = in.readString();
        picUrl = in.readString();
        originalPicUrl = in.readString();
        keyGifPicUrl = in.readString();
        picWidth = in.readInt();
        picHeight = in.readInt();
        isGif = in.readInt();
        isKeyGif = in.readInt();
        isPicLoad = in.readInt();
        isFail = in.readInt();
    }


}
